﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_UpdateJump]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_UpdateJump];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_UpdateJump]
    @FlowID int,
    @StepID int,
    @Priority int,
    @FieldName nvarchar(50),
    @Compare nvarchar(50),
    @CompareValue float,
    @ToStepID int
AS
IF EXISTS(SELECT 1 
            FROM 
                uds_flow_jump 
            WHERE     flow_id = @flowid 
                and step_id = @stepid 
                and priority = @priority
        )
BEGIN
    UPDATE uds_flow_jump 
        SET
            FieldName    = @FieldName,
            Compare        = @Compare,
            CompareValue    = @CompareValue,
            To_Step_ID    = @ToStepID
        WHERE     flow_id     = @flowid 
            and step_id     = @stepid
            and priority     = @priority

    RETURN 0
END 
ELSE
    RETURN -1